package Covid2;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class Covid2Reducer extends Reducer<Text,CovidBean,Text,CovidBean> {

    @Override
    protected void reduce(Text key, Iterable<CovidBean> values, Reducer<Text, CovidBean, Text, CovidBean>.Context context) throws IOException, InterruptedException {

        long count1=0,count2=0;

        for (CovidBean v:values)
        {
            count1=count1+v.infect;
            count2=count2+v.death;
        }

        CovidBean outvalue = new CovidBean(count1,count2);
        context.write(key,outvalue);
    }
}
